package com.ruoyi.common.utils;


import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;

/**
 * 类名称：Identities    <br>
 * 类描述： 封装各种生成唯一性ID算法的工具类.   <br>
 *
 * @author :yanlixiong
 * @date :2021-10-25 13:41:58
 */
public class IdentitiesUtils {

    private static SecureRandom random = new SecureRandom();

    /**
     * 封装JDK自带的UUID, 通过Random数字生成, 中间有-分割.
     *
     * @return 带有分隔符的UUID
     */
    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    /**
     * 封装JDK自带的UUID, 通过Random数字生成, 中间无-分割.
     *
     * @return 不带有分隔符的UUID
     */
    public static String uuid2() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    /**
     * 使用SecureRandom随机生成Long.
     *
     * @return 随机数
     */
    public static long randomLong() {
        return Math.abs(random.nextLong());
    }

    public static double getGeoHeight() {
        // 创建 SecureRandom 对象
        SecureRandom secureRandom = new SecureRandom();
        // 生成 10000 到 15000 之间的随机 Double 数字
        double min = 10000;
        double max = 15000;
        return min + secureRandom.nextDouble() * (max - min);
    }

    public static long getTimestampVariation() {
        int randomNumber = random.nextInt(30000) + 50000;
        return randomNumber;
    }


    public static int[] generateRandomNumbers() {
        Random random = new Random();
        // 生成两个 0 到 100 之间的随机数
        int firstCut = random.nextInt(101);
        int secondCut = random.nextInt(101);

        // 确保 firstCut 小于 secondCut
        if (firstCut > secondCut) {
            int temp = firstCut;
            firstCut = secondCut;
            secondCut = temp;
        }

        // 计算三个数
        int num1 = firstCut;
        int num2 = secondCut - firstCut;
        int num3 = 100 - secondCut;

        return new int[]{num1, num2, num3};
    }

    public static void main(String[] args) {
        for (int i = 0; i <5 ; i++) {
            System.out.println(getTimestampVariation());
        }

    }
}

